<?php
	ob_start();
	session_start();
	
	foreach($_REQUEST as $key => $value)  {
		$$key = $value;
		//echo $key.'='.$value."<br>";
	}
	
	include("../include/class.function.php");
	$inancm = new inancm();	
	error_reporting(E_ALL ^ E_NOTICE);
	
	$password = '';
	//$inancm->pre($_SESSION);
	
?>
<?php if (!empty($_SESSION['pass_actived'])) { ?>
     <META HTTP-EQUIV="Refresh" CONTENT="0;URL=index.php">
<?php } ?>

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
	<!--<meta name="viewport" content="width=device-width, initial-scale=1"> -->
    <meta charset="utf-8">
    <title>Login Page - iNanCM Admin</title>
    <link rel="shortcut icon" href="../favicon.ico" type="image/x-icon">
    <link rel="icon" href="../favicon.ico" type="image/x-icon">
    <link rel="stylesheet" type="text/css" href="css/admin.css">
    <link rel="stylesheet" type="text/css" href="css/alert.css">
    
    <script src="../js/jquery-1.7.2.js"></script>
    <script src="../js/jquery-1.7.2.min.js"></script>
  
    
    <style type="text/css">
        .debug_css {
            border:#F60 1px dotted;
        }
    </style>		
  </head>
    
    <script type="text/javascript">
    function login(){
        console.log($("#username").val());
        var setText = '';
        var pass = 1;
        var chkMem = 0;
        if ($("#username").val()==''){
            $("#username").closest('div').addClass("f_error");
            setText = 'โปรดกรอก username';
            pass = 0;		
        }
        
        if ($("#password").val()==''){
            $("#password").closest('div').addClass("f_error");
            if (setText == ''){
                setText = 'โปรดกรอก password';
            } else {
                setText = setText+', password';
            }
            pass = 0;
        }
    
        
        if ($('#chkMem').is(':checked')){
            chkMem = 1;
        } 
        
         console.log(setText);
        if (pass){
    
            $.post("../include/class.login.php", { 
                process: "login",
                username: $("#username").val(),
                password: $("#password").val(),
                chkMem : chkMem
            }, 
                function(data){
                    $("#divPostData").html(data);
                }
            );
        } else {
			$("#divPostData").fadeIn(100);
            $("#divPostData").html("<div class='error'>"+setText+"</div>");
			//$("#divPostData").fadeOut(1500);
        }
    }
    </script>
		
	</head>
  
	<body>	
    	
        <div id="loginform" style="margin-top:20px;">
        <div id="facebook"><i class="fa fa-facebook"></i>
        	<div id="divPostData" class="info">Connect to Admin</div></div>
        <div id="mainlogin">
        <div id="or"><></div>
        <h1>Login to Admin</h1>
        <form action="#">
        	<input type="text" id="username" placeholder="username or email" value="" required>
        	<input type="password" id="password" placeholder="password" value="" required>
        	<button type="button" onClick="login();">></button>
        </form> 
        <div id="note"><a href="#">Forgot your password?</a></div>
        </div>
        </div>
  

</body>
</html>